Manchester-NW5-Zaw Khing-JavaScript-Core-1-Week1#397
Conversation
Dominic-Taylor-Dev
left a comment
There was a problem hiding this comment.
Really good job - well done!
|
|
||
| function trimWord(word) { | ||
| return wordtrim(); | ||
| wordtrim = word.trim(); |
There was a problem hiding this comment.
You don't really use this variable so could get away with just directly returning word.trim()
|
|
||
| function getStringLength(word) { | ||
| return "word".length(); | ||
| wordLength = word.length; |
There was a problem hiding this comment.
same as above - no need for separate variable
| function multiply(a, b, c) { | ||
| a * b * c; | ||
| return; | ||
| var sum = a * b * c; |
| function getRandomNumber() { | ||
| return Math.random() * 10; | ||
| function getRandomNumber() { //create function called getRandomNumber | ||
| return Math.random() * 10; //returns a random number between 0 and 9 |
There was a problem hiding this comment.
If you want an integer (whole number) then you will still need to round this down. To do that, you can use Math.floor() (see here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)
|
|
||
| function calculateSalesTax() {} | ||
| function calculateSalesTax(productPrice) { | ||
| const salesTax = (productPrice / 100) * 20; |
There was a problem hiding this comment.
Where you have numbers that don't inherently mean anything e.g. 20 here, it's often good to assign them to a variable to make their meaning clear in the code e.g.:
const SALES_TAX_RATE = 20;
const salesTax = (productPrice / 100) * SALES_TAX_RATE;
If you're wondering why the caps, you'll often see constants expressed like this in JavaScript
| @@ -1,2 +1,14 @@ | |||
| var numberOfStudents = 15; | |||
| var numberOfMentors = 8; | |||
| var sum = numberOfStudents + numberOfMentors; | |||
There was a problem hiding this comment.
Try to use let or const always and never var
Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in
HOW_TO_MARK.mdin the root of this repositoryYour Details
Homework Details
Notes
What did you find easy?
What did you find hard?
What do you still not understand?
Any other notes?